import request from "@/utils/request";

// 查询组织列表
export function listDept(query) {
  return request({
    url: "/system/dept/list",
    method: "get",
    params: query,
  });
}

// 查询组织列表（排除节点）
export function listDeptExcludeChild(deptId) {
  return request({
    url: "/system/dept/list/exclude/" + deptId,
    method: "get",
  });
}

// 查询组织详细
export function getDept(deptId) {
  return request({
    url: "/system/dept/" + deptId,
    method: "get",
  });
}

// 查询组织详细
export function syncDept() {
  return request({
    url: '/system/dept/syncData',
    method: 'get'
  })
}

// 查询组织下拉树结构
export function treeselect(params) {
  return request({
    url: "/system/dept/treeselect",
    method: "get",
    params,
  });
}

// 根据角色ID查询组织树结构
export function roleDeptTreeselect(roleId) {
  return request({
    url: "/system/dept/roleDeptTreeselect/" + roleId,
    method: "get",
  });
}

// 新增组织
export function addDept(data) {
  return request({
    url: "/system/dept",
    method: "post",
    data: data,
  });
}

// 修改组织
export function updateDept(data) {
  return request({
    url: "/system/dept",
    method: "put",
    data: data,
  });
}

// 删除组织
export function delDept(deptId) {
  return request({
    url: "/system/dept/" + deptId,
    method: "delete",
  });
}

// 获取当前用户所属组织工厂
export function getUserFactory(userId) {
  return request({
    url: "/system/user/getFactory/" + userId,
    method: "get",
  });
}

// 获取当前用户所属组织工厂
export function getFactoryList(query) {
  return request({
    url: "/system/dept/getFactoryList",
    method: "get",
    params: query,
  });
}
// 筛选组织列表 deptType
export function getDeptList(query) {
  return request({
    url: "/system/dept/queryByDeptType",
    method: "get",
    params: query,
  });
}
export function getFactoryTree(query) {
  return request({
    url: "/system/dept/getFactoryTree",
    method: "get",
    params: query,
  });
}

// 查询工厂、工段、产线、工艺段
export function depeIdSelectList(query) {
  return request({
    url: "/system/dept/depeIdSelectList",
    method: "get",
    params: query,
  });
}

// getClassesMode
export function getClassesMode(query) {
  return request({
    url: "/system/deptClassesModeHis/getClassesMode",
    method: "get",
    params: query,
  });
}
